<template>
	<view class="main">
		<u-navbar :is-back="true" :title="i18n.navbar.manage_accounts" :background="background" :border-bottom="false" title-color="#000000"
			back-icon-color="#000">
		</u-navbar>
		<view class="all">

			<view class="info">
				<view class="title">
					{{i18n.account_manage.name}}
				</view>
				<view class="cont">
					<!-- <text>{{shopinfo.realName}}</text> -->
					<input type="text"  v-model="realName" :placeholder="i18n.account_manage.name"/>
				</view>
			</view>
			<view class="info">
				<view class="title">
					{{i18n.account_manage.useraccount}}
				</view>
				<view class="cont">
					<text>{{shopinfo.account}}</text>
				</view>
			</view>
			<view class="content">
				<view class="bot">
					<text>{{i18n.account_manage.new}}</text>
					<input type="text" :placeholder="i18n.account_manage.new"  v-model="pwd"/>
				</view>
				<view class="bot">
					<text>{{i18n.account_manage.confirm}}</text>
					<input type="text" :placeholder="i18n.account_manage.confirm"  v-model="newpwd"/>
				</view>
			</view>
			
		</view>
		<view class="button" @click="update">
			确定
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#fff',
				},
				shopinfo:''
			}
		},		
		computed: {
			i18n() {
				return this.$t('message')
			},
		},
		onShow(){
			this.lang()
		},
		onLoad() {
			this.getsuperuser()
		},
		methods: {
			getsuperuser(){
				global.$http.request({
					url:'/api/admin/merchant/getAdminInfoByToken',
					header: {
						'Authori-zation': uni.getStorageSync('token') //自定义请求头信息
					},
					method: 'GET',
				}).then(res=>{
					if(res.data.code==200){
						this.shopinfo=res.data.data
					}
				})
			},
			update(){
				if(this.pwd!=this.newpwd){
					uni.showToast({
						title:'两次密码输入不一致',
						icon:'none',
						duration:500
					})
				}else{
					global.$http.request({
						url:'/api/admin/merchant/admin/update',
						header: {
							'Authori-zation': uni.getStorageSync('token') //自定义请求头信息
						},
						data:{
							id:this.shopinfo.id,
							realName:this.realName,
							account:this.shopinfo.account,
							pwd:this.newpwd,
						}
					}).then(res=>{
						if(res.data.code==200){
							console.log(res.data.data);
							uni.showToast({
								title:res.data.messages,
								icon:'none',
								duration:500
							})
						}
						
					})
				}
			},
		lang() {
			this._i18n.locale = uni.getStorageSync('select')
		},
		}
	}
</script>

<style lang="scss">
	page {
		font-family: PingFang SC;
		background-color: #f7f7f7;

		.main {

			.shop_info {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #304156;
				padding-right: 19rpx;
			}

			.all {
				margin-top: 10rpx;

				.info {
					background-color: #fff;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 31rpx 22rpx;
					margin-bottom: 2rpx;

					.title {
						font-size: 28rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #000000;
					}
					.cont {
						font-size: 28rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #808080;
						input{
							font-size: 28rpx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #808080;
							text-align: right;
						}
					}

					
				}

				.content {
					.bot {
						background-color: #fff;
						margin-bottom: 2rpx;
						padding: 31rpx 22rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;

						font-size: 28rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;

						text {
							color: #000000;
						}

						input {
							text-align: right;
						}
					}
				}
			}
			.button{
				position: absolute;
				bottom: 0;
				width: 750rpx;
				height: 98rpx;
				background: #304156;
				text-align: center;
				line-height: 98rpx;
				
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
			}
		}
	}
</style>
